package com.jx.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jx.service.UserService;
import com.jx.servicrimpl.UserServiceImpl;

public class DeleteUserController extends HttpServlet{
	UserService deluser = new UserServiceImpl();
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
		throws ServletException, IOException {
	// TODO Auto-generated method stub
	doPost(req, resp);
}
@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
	PrintWriter  pw =  resp.getWriter();
	int m = 0;
	String uid[] = req.getParameterValues("uid");
	for (String userid : uid) {
		int i = Integer.parseInt(userid);		
		if (deluser.deleteUserByUidService(i)==true) {			
			m = 1;
		}

		else{
			System.out.println(22222);
			m = 0;
		}
			
	}
	
	if(m==1){
		pw.write("1");
	}
	if (m==0) {
		pw.write("0");
	}
	}
}
